﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>登陆</title>
    <link href="../../Content/assets/lib/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <link href="../../Content/assets/css/style.css" rel="stylesheet" />
</head>
<body>
        <!-- 内容部分开始 -->
        @using (Ajax.BeginForm("ProcessLogin", "UserLogin",new AjaxOptions() { OnSuccess = "afterLogin" }))
        {
            <!--下面是用户名输入框-->
            <div class="input-group">
                <span class="input-group-addon" id="basic-addon1"></span>
                <input type="text" class="form-control" id="username" name="username" placeholder="邮箱/用户名/已验证手机" />
            </div>
            <br>
            <!--下面是密码输入框-->
            <div class="input-group">
                <span class="input-group-addon" id="basic-addon1"></span>
                <input type="password" class="form-control" id="password" name="password" aria-describedby="basic-addon1" placeholder="密码" />
            </div>
            <br>
            <!--下面是验证码输入框-->
            <div class="input-group">
                <span class="input-group-addon" id="basic-addon1"></span>
                <input type="text" class="form-control" id="vcode" name="vcode" aria-describedby="basic-addon1" placeholder="密码" />
                <span class="input-group-addon" style="padding: 0 2px; cursor: pointer">
                    <img id="vcode_img" src="/UserLogin/ShowVCode" data-src="/UserLogin/ShowVCode" width="100" height="32" alt="验证码" title="点击切换验证码">
                </span>
            </div>
            <br>
            <!--下面是登陆按钮,包括颜色控制-->
            <button type="submit" style="width:280px;" class="btn btn-danger btn-default">登 录</button>
        }
    <script src="../../Content/assets/lib/jquery/jquery-1.11.0.js"></script>
    <script src="~/Scripts/jquery.unobtrusive-ajax.js"></script>
    <script src="../../Content/assets/lib/bootstrap/js/bootstrap.js"></script>
    <script type="text/javascript">
        $('#vcode_img').click(function () {
            $(this).attr('src', $(this).data('src') + '?v=' + Math.random());
            //console.log(11);
            //return confirm("删除");
        });

        //登陆成功后执行此方法
        function afterLogin(data) {
            if (data == "ok") {
                //登陆成功
                alert(data);
                window.location.href = "/";
            }
            else {
                alert(data);
                $('#vcode_img').click(function () {
                    $(this).attr('src', $(this).data('src') + '?v=' + Math.random());
                    console.log(11);
                });
            }
        }
    </script>
</body>
</html>
